﻿@{
    ViewBag.Title = "日程安排查询";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}
@section styles{
    <link href="@Url.Content("~/Content/css/common/bootstrap-table/bootstrap-table.min.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/css/common/animate/animate.min.css")" rel="stylesheet" />
}
<div id="dMain">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <a class="btn btn-sm btn-warning radius" onclick="backfrom()">
                    <i class="iconfont icon-fanhui"></i>
                    返回日历
                </a>
            </div>
            <div class="ibox-content">
                <div class="dSearch">
                    <input name="CAL_TIME" type="text" id="CAL_TIME" class="form-control" placeholder="开始时间" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" style="width:95px;" autocomplete="off">
                    至
                    <input name="END_TIME" type="text" id="END_TIME" class="form-control" placeholder="结束时间" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" style="width:95px;" autocomplete="off">

                    <select name="CAL_TYPE" id="CAL_TYPE" class="form-control" style="width:130px;">
                        <option selected="selected" value="">-- 事务类型 --</option>
                        <option value="1">工作事务</option>
                        <option value="2">个人事务</option>
                    </select>
                    <select name="CAL_LEVEL" id="CAL_LEVEL" class="form-control" style="width:130px;">
                        <option selected="selected" value="">-- 优先级 --</option>
                        <option value="1">重要/紧急</option>
                        <option value="2">重要/不紧急</option>
                        <option value="3">不重要/紧急</option>
                        <option value="4">不重要/不紧急</option>
                    </select>
                    <input name="CONTENT" type="text" id="CONTENT" class="form-control" placeholder="事务内容" style="width:150px;" autocomplete="off">
                    <select name="OVER_STATUS" id="OVER_STATUS" class="form-control" style="width:130px;">
                        <option selected="selected" value="">-- 完成状态 --</option>
                        <option value="0">未完成</option>
                        <option value="1">已完成</option>
                    </select>
                    <a id="lbtnSearch" class="btn btn-sm btn-primary btn-success" onclick="customSearch()"><i class="iconfont icon-sousuo"></i>&nbsp;快速检索</a>
                </div>
                <table id="CalendarDataTable"></table>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/bootstrap-table.min.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/locale/bootstrap-table-zh-CN.min.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/bootstrap-table-export.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/tableExport.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/bootstrap-table-cookie.js")"></script>
    <script src="@Url.Content("~/Content/js/common/from.js")"></script>
    <script>
    //var tabHeight = 0;
        $(function () {
            $('#CalendarDataTable').bootstrapTable({
                //  height: tabHeight + 50,
                url: '/Personal/Calendar/GetTableJsonResult', //请求后台的URL（*）
                method: 'get', //请求方式（*）
                //data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                dataType: "json",
                columns: [
                    { checkbox: true },
                    {
                        title: "开始时间", field: 'CAL_TIME', align: 'center', formatter: function (value, row, index) {
                            return new Date(value).Format("yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        title: "结束时间", field: 'END_TIME', align: 'center', formatter: function (value, row, index) {
                            return new Date(value).Format("yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        title: "事务类型", field: 'CAL_TYPE', align: 'center',
                        formatter: function (value, row, index) {
                            if (value == "1") {
                                return "工作事务";
                            }
                            else if (value == "2") {
                                return "个人事务";
                            }
                        }
                    },
                    {
                        title: "优先级", field: 'CAL_LEVEL', align: 'center',
                        formatter: function (value, row, index) {
                            if (value == "1") {
                                return "重要/紧急";
                            }
                            else if (value == "2") {
                                return "重要/不紧急";
                            }
                            else if (value == "3") {
                                return "不重要/紧急";
                            }
                            else if (value == "4") {
                                return "不重要/不紧急";
                            }
                        }
                    },
                    {
                        title: "事务内容", field: 'CONTENT', align: 'center'
                    },       
                    {
                        title: "提前提醒时间", field: 'BEFORE_REMAIND', align: 'center', formatter: function (value, row, index) {
                            return new Date(value).Format("yyyy-MM-dd hh:mm:ss");
                        }
                    },
                    {
                        title: "所属者", field: 'OWNER', align: 'center'
                    },
                    {
                        title: "参与者", field: 'TAKER', align: 'center'
                    },
                    {
                        title: "全天", field: 'ALLDAY', align: 'center',
                        formatter: function (value, row, index) {
                            if (value == "1") { return '<span>是</span>'; } else { return '<span>否</span>'; }
                        }
                    },
                    {
                        title: "添加模块", field: 'FROM_MODULE', align: 'center'
                    },
                    {
                        title: "完成状态", field: 'OVER_STATUS', align: 'center',
                        formatter: function (value, row, index) {
                            if (value == "1") { return '<span>是</span>';} else { return '<span>否</span>'; }
                        }
                    },
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                pageSize: 10,//分页条数
                clickToSelect: false,//设置true 将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "Calendar",//cookie键值
                pagination: true,//是否分页
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: false,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: true,//是否显示行间隔色
                detailView: false,//是否显示切换视图列
                queryParams: function (params) {
                    var param = {};
                    //var arr = $("form").serialize();
                    //$.param(arr);
                    //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    $('.dSearch').find('[name]').each(function () {
                        var value = $(this).val();
                        if (value != '') {
                            //if (!param.find($(this).attr('name')))
                            param[$(this).attr('name')] = value;
                        }
                    });
                    return param;
                },
                //detailFormatter: detailFormatter,//卡片视图内容格式化
                onDblClickRow: function (row, obj) { //双击行事件
                },
                //onClickRow: function (row, obj) { //单击行事件
                //    $(obj).parent().find("tr").removeClass("selected");
                //    $(obj).addClass("selected");

                //    ////根据选中的行获取子表数据
                //    //GetSonData(row.ID);
                //},
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            var str = "<span class=\"bg-yellow\">" + text + "</span>";
                            var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).text().replaceAll(text, str);
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                        })
                    }
                }
            });
        });
        function customSearch(text) {
            $('#CalendarDataTable').bootstrapTable('refresh');//刷新Table，Bootstrap Table 会自动执行重新查询
        }

        function backfrom() {
            location.href = "/Personal/Calendar/Index";
        }
	  //$("#lbtnSearch").click(function () {
   //       var _startTime = $("#txtCAL_TIME").val();
   //       var _endTime = $("#txtEND_TIME").val();
   //       var _calType = $('#ddlCAL_TYPE option:selected').val();
   //       var _calLevel = $("#ddlCAL_LEVEL").val();
   //       var _ontent = $("#txtCONTENT").val();
   //       var _overStatus = $("#OVER_STATUS").val();
   //         $.ajax({
   //             type: "post",
   //             url: "/Calendar/GetTableJsonResult",
   //             data: { startTime: _startTime, endTime: _endTime, calType:_calType, calLevel: _calLevel, content: _ontent, overStatus:_overStatus},
   //             dataType: "json",
   //             success: function (json) {
   //                 $("#SysCodeDataTable").bootstrapTable('load', json);
   //             }
   //         });
   //     });

    </script>
}
